package com.guigu.oss.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 读取配置文件内容，将内容封装到ConstantPropertiesUtils类中
 */
@Component
public class ConstantPropertiesUtils implements InitializingBean {


    //读取配置文件内容
    @Value("${aliyun.oss.endpoint}")
    private String endpoint;
    @Value("${aliyun.oss.accessKeyId}")
    private String keyId;
    @Value("${aliyun.oss.accessKeySecret}")
    private String keySecret;
    @Value("${aliyun.oss.bucketName}")
    private String bucketName;
    @Value("${aliyun.oss.file.test-images}")
    private String testImages;



    public static String END_POINT;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String BUCKET_NAME;
    public static String TEST_IMAGES;

    // spring容器中bean对象创建后，自动设置对象属性的方法
    @Override
    public void afterPropertiesSet() throws Exception {
        END_POINT = endpoint;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        BUCKET_NAME = bucketName;
        TEST_IMAGES = testImages;
    }
}
